<template>
    <div style="width: 100%;">
        <el-form :inline="true">
            <el-form-item>
                <el-select v-model="params.tenderId" :value="params.tenderId">
                    <el-option label="招标编号" value=""></el-option>
                    <el-option
                            v-for="tender in tenderPurchasePlanList"
                            :key="tender.id"
                            :label="tender.id"
                            :value="tender.id"
                    ></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-input v-model="params.projectName" placeholder="项目名称" :clearable="true"></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="params.companyName" placeholder="公司名称" :clearable="true"></el-input>
            </el-form-item>
            <el-form-item>
                <el-select v-model="params.projectType" :value="params.projectType">
                    <el-option label="项目类型" value=""></el-option>
                    <el-option
                            v-for="projectType in projectTypeList"
                            :key="projectType.typeId"
                            :label="projectType.typeName"
                            :value="projectType.typeId"
                    ></el-option>
                </el-select>
            </el-form-item>
            <el-form-item style="margin-left: 10px">
                <el-button @click="handleSearch" type="primary">检索</el-button>
            </el-form-item>
        </el-form>

        <el-table :data="pageResult.records">
            <el-table-column label="序号" type="index"></el-table-column>
            <el-table-column label="招标编号" prop="tenderId"></el-table-column>
            <el-table-column label="项目名称" prop="projectName"></el-table-column>
            <el-table-column label="项目类型" prop="projectType"></el-table-column>
            <el-table-column label="报价公司" prop="companyName"></el-table-column>
            <el-table-column label="报价日期" prop="createdate"></el-table-column>
            <el-table-column label="报价金额(万)" prop="offer">
                <template slot-scope="scope">
                    <span style="color: red;;font-weight: 700">{{scope.row.offer/10000}}</span>
                </template>
            </el-table-column>
        </el-table>
        <el-divider></el-divider>

        <el-footer class="case-list-footer">
            <el-pagination
                    style="margin: 10px auto"
                    background
                    layout="total , sizes ,prev, pager, next,jumper"
                    :page-sizes="[5,10,15,20]"
                    :total="pageResult.total"
                    :page-size="pageResult.size"
                    class="pagination"
                    @current-change="handleIndexChange"
                    @size-change="handleSizeChange"
            >
            </el-pagination>
        </el-footer>
    </div>
</template>

<script>
    import {TenderBiddingHistoryService} from "../../../model/gs/TenderBiddingHistoryService";
    import {ProjectTypeService} from "../../../model/gs/ProjectTypeService";
    import {TenderPurchasePlanService} from "../../../model/gs/TenderPurchasePlanService";

    const tenderBiddingHistoryService = TenderBiddingHistoryService.getInstance()
    const projectTypeService = ProjectTypeService.getInstance()
    const tenderPurchasePlanService = TenderPurchasePlanService.getInstance()

    export default {
        data() {
            return {
                plan: {},
                params: {
                    tenderId: '',
                    projectName: '',
                    projectType: '',
                    status: '2',
                    type: 'opponent',
                    companyName:''
                },
                projectTypeList: [],
                tenderPurchasePlanList:[],
                pageResult: []
            }
        },
        methods: {
            getProjectTypeList() {
                projectTypeService.getList().then(response => {
                    if (response.data.code === 0) {
                        this.projectTypeList = response.data.data
                    }
                })
            },
            getTenderPurchasePlanList() {
                tenderPurchasePlanService.list().then(response => {
                    if(response.data.code === 0){
                        this.tenderPurchasePlanList = response.data.data
                    }
                })
            },
            getTenderBiddingHistoryList() {
                tenderBiddingHistoryService.getPageList(this.params).then(response => {
                    if (response.data.code === 0) {
                        this.pageResult = response.data.data
                    }
                })
            },
            handleSearch() {
                this.params.page = 1
                this.getTenderBiddingHistoryList()
            },
            handleIndexChange(index) {
                this.params.page = index
                this.getTenderBiddingHistoryList()
            },
            handleSizeChange(size) {
                this.params.size = size
                this.getTenderBiddingHistoryList()
            }
        },
        created() {
            this.getTenderBiddingHistoryList()
            this.getTenderPurchasePlanList()
            this.getProjectTypeList()
        }
    }
</script>

<style scoped>

</style>
